﻿//全局ajax控制，用于session超时、无权限时 提示
$.ajaxSetup({
	cache: false, //close AJAX cache
	contentType:"application/x-www-form-urlencoded;charset=utf-8", 
	complete:function(XHR,textStatus){   
        var resText = XHR.responseText;
        if(resText=='ajaxSessionTimeOut'){   
        	sessionTimeOut();
        }
        else if(resText=='ajaxNoLimit'){   
        	noLimit();
        }
        /*else if(resText=='ajaxException'){   
        	globalException();
        } */
    } 
});

function sessionTimeOut(){
	$.messager.alert('操作提示','用户登录会话已过期，请重新登录！','warning');
	setTimeout('window.top.location.href ="'+ basePath + '/login/exit.as"', 1200);
}

function noLimit(){
	$.messager.alert('操作提示','无相应操作权限，请联系系统管理员！','warning');
}


function globalException(){
	$.messager.alert('操作提示','系统内部异常！请联系系统管理员！','warning');
}


function reload_dg($dg) {
	$dg.datagrid('reload');
	if ($dg.datagrid('getRows') == 0) {
		var pagination = $dg.datagrid('getPager');
		var options = pagination.data("pagination").options;  
		var pageNumber = options.pageNumber;
		if (pageNumber > 1){
			$dg.datagrid({pageNumber : pageNumber -1});
		}
	}
}

function reset_pagenum($dg) {
	var pagination = $dg.datagrid('getPager');
	var options = pagination.data("pagination").options;  
	var pageNumber = options.pageNumber;
	if (pageNumber > 1){
		$dg.datagrid({pageNumber : 1});
	}
}